<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<div class="board_contents">
	<h1>Schedule</h1>
		<ul class="token">	
			<li><img src="resources/images/work_title.jpg"/>업무시작일</li>
			<li><img src="resources/images/work_title_end.jpg"/>업무종료일</li>
			<li><img src="resources/images/schedule_title.jpg"/>개인 일정</li>
		</ul>
		<input type="button" class="btn" style="float: left;" onclick="get_schedule(${calendar.currentYear}, ${calendar.currentMonth - 1})"value="이전" /> 
		<div id="schedule_date">${calendar.currentYear } 년/ ${calendar.currentMonth +	1 } 월</div>
		<input type="button" class="btn" style="margin-right: 130px;"onclick="get_schedule(${calendar.currentYear}, ${calendar.currentMonth + 1})"value="이후" />
		<input type="button" class="btn" value="주간" onclick="schedule_week(${calendar.currentYear }, ${calendar.currentMonth - 1 }, ${calendar.currentDay })" >
		<input type="button" class="btn" style="width: 120px;" value="개인 일정 리스트" onclick="schedule_list(${emp.empNo})" >
		<input type="button" id="create-user" class="btn" style="width: 120px;  float:inherit;" value="개인 일정 추가" >
	<div id="schedule_list">
		<div id="dialog-form">
		    <ul>
			    <li>>일&nbsp;&nbsp;&nbsp;정<input type="text" name="title" id="title" /></li>
			    <li>>시작일<input type="text" name="startDate" id="startDate"  /></li>
			    <li>>마감일<input type="text" name="endDate" id="endDate"/></li>
			    <li><textarea name="contents" id="contents"></textarea></li>
		    </ul>
			<input type="button" id="create-submit" style="margin-left: 100px" class="btn" value="일정추가"  onclick="schedule_add_action(${emp.empNo})"/>
			<input type="button" id="create-reset" class="btn" value="취소"/>
		</div>
		<script>
			$("input#startDate").datepick({
				dateFormat : 'yyyy-mm-dd'
			});
			$("input#endDate").datepick({
				dateFormat : 'yyyy-mm-dd'
			});
		</script>
		<script type="text/javascript">
			$(document).ready(function(){
			$('input#create-user').click(buttonClick);
			$('input#create-submit').click(buttonSubmit);
			$('input#create-reset').click(buttonReset);
			});
			
			function buttonClick(){
				$('div#dialog-form').fadeIn("slow");
			}
			function buttonSubmit(){
				$('div#dialog-form').fadeOut("slow");
			}
			function buttonReset(){
				$('div#dialog-form').fadeOut("slow");
			}
		</script>
	<table id="schedule_table">
		<tr>
			<c:forEach items="${calendar.dayNames }" var="dayName">
				<th>${dayName}</th>
			</c:forEach>
		</tr>
		<tr>
			<c:forEach begin="1" end="${calendar.firstDay - 1}">
				<td><span id="day"></span></td>
				<c:set var="col" value="${col + 1 }"></c:set>
			</c:forEach>
			<c:forEach begin="1" end="${calendar.lastDay }" var="day">
			<td id="day_box">
				<c:choose>
					<c:when test="${col == 0 }">
						<span id="sunday">${day }</span> 
					</c:when>
					<c:when test="${col == 6}">
						<span id="satday">${day }</span>
					</c:when>
					<c:when test="${day == calendar.currentDay }">
						<span id="today">${day } Today!</span>
					</c:when>
					<c:otherwise>
						<span id="day">${day }</span>
					</c:otherwise>
				</c:choose>
				<c:forEach var="work" items="${workList }">
								<c:if test="${work.workStartTime.getMonth() + 1
							== (calendar.currentMonth + 1) && work.workStartTime.getDate() == day}">
									<div id="work_title" title="업무일정 / 상태 : ${work.workState} / 담당자 : ${work.name}" onclick="pick_work2(${work.workNo})">${work.workTitle
										}</div>
									<br>
								</c:if>
				</c:forEach>
				<c:forEach var="work" items="${workList }">
								<c:if test="${work.workDeadTime.getMonth() + 1
							== (calendar.currentMonth + 1) && work.workDeadTime.getDate() == day}">
									<div id="work_title_end" title="업무일정 / 상태 : ${work.workState} / 담당자 : ${work.name}" onclick="pick_work2(${work.workNo})">${work.workTitle
										}</div>
									<br>
								</c:if>
				</c:forEach>
				<c:forEach var="schedule" items="${scList }">
								<c:if test="${schedule.scheduleStartDate.getMonth() + 1
							== (calendar.currentMonth + 1) && schedule.scheduleStartDate.getDate() == day}">
									<div title="개인일정 / 내용 : ${schedule.scheduleContents }" id="schedule_title">${schedule.scheduleTitle}</div>
									<br>
								</c:if>
				</c:forEach>
				</td>
				<c:set var="col" value="${col + 1 }" />
				<c:if test="${col == 7 }">
					<c:set var="col" value="0" />
		</tr>
		<tr>
			</c:if>
			</c:forEach>

			<c:forEach begin="${col }" end="6">
				<td></td>
				<c:if test="${col == 5}">
		</tr>
		</c:if>
		</c:forEach>
	</table>
	</div>
	<script>
		$('span#work_title').tooltip({position:{my:"left+30 center",at:"right top"},
			hide: {effect:"fadeOut", duration:200},
			show: {effect:"fadeIn", duration:200}
			
		});
		$('span#schedule_title').tooltip({position:{my:"left+30 center",at:"right top"},
			hide: {effect:"fadeOut", duration:200},
			show: {effect:"fadeIn", duration:200}
			
		});
	</script>
</div>
<!-- board_contents end div -->
</div>
<!-- board end div  -->